import React, {memo, useEffect} from 'react'
import type {FC, ReactNode} from 'react'
import { shallowEqual} from 'react-redux'
import {useAppSelector,useAppDispatch} from '@/store'
import {changeMessage} from '@/store/modules/demo'
import request from '@/utils/request'
interface IProps {
  children?: ReactNode
}

const Recommend: FC<IProps> = (props) => {
  const state = useAppSelector((state)=>({
    count: state.counter.count,
    message: state.counter.message
  }),shallowEqual)
  const dispatch = useAppDispatch()
  function updateMessage(){
    dispatch(changeMessage('redux真好玩'))
  }
  useEffect(()=>{
    // 获取轮播图数据
    // request.get({url:'/banner?type=0'}).then(res=>{
    //   console.log(res)
    // })
  },[])
  return (
    <div>
      <button onClick={updateMessage}>修改redux的值</button>
      Recommend{state.message}{state.count}</div>
  )

}

export default memo(Recommend)